﻿@model Bricks.Site.Models.DBViewModel.Contract.VMConstructionContractEstimates
@{
    ViewBag.Title = "ConstructionContractEstimateBillList";
    Layout = "~/Views/Shared/_UserPage.cshtml";
}

<script type="text/javascript">
    $(function () {
        $("#ContractStages").combobox({
            editable: false, panelHeight: "auto",
            valueField: 'ID',
            textField: 'ContractStages',
            url: '/ContractInfo/GetConstructionContractStagesList?contractID=' + $('#hContractID').val(),
            onLoadSuccess: function () {
                var data = $("#ContractStages").combobox('getData');
                if (data.length > 0) {
                    $("#ContractStages").combobox('select', $('#hContractStagesID').val());
                }
            },
            onSelect: function (record) {
                initTable(record.ID);
            }
        });
    });

    function initTable(contractStages) {
        $('#estimateBillDataGrid').datagrid({
            url: '/ContractInfo/GetConstructionContractEstimateBillList?contractStagesID=' + contractStages,
            fitColumns: true,
            nowrap: true,
            autoRowHeight: false,
            striped: true,
            collapsible: true,
            pagination: true,
            pageSize: 20,
            rownumbers: true,
            remoteSort: false,
            idField: 'ID',
            singleSelect: true,
            columns: [[
                        { title: '清单号', field: 'BillCode', width: 70, sortable: true },
                        { title: '项目内容', field: 'PorjectContent', width: 200, sortable: true },
                        { title: '合同总额', field: 'ContractMoney', width: 70, sortable: true },
                        { title: '施工图金额', field: 'ConstructionDrawMoney', width: 70, sortable: true },
                        { title: '变更增减额', field: 'AlterChangeMoney', width: 70, sortable: true },
                        { title: '变更后总额', field: 'AfterAlterMoney', width: 70, sortable: true },
                        { title: '到本期末完成', field: 'CurrentUnfinished', width: 70, sortable: true },
                        { title: '到上期末完成', field: 'LastUnfinished', width: 70, sortable: true },
                        { title: '本期完成', field: 'CurrentFinished', width: 70, sortable: true },
            ]],
            onLoadSuccess: function (data) {
                //if (data.rows.length > 1) {
                //    var tTable = $("#estimateBillDataGrid");
                //    mergeRowCells(tTable, "ContractStages,ContractorDeclareMoney", 0, data.rows.length);
                //}
            }
        });
    }
</script>

<div class="frombox datagrid-body" style="padding-bottom: 5px;height:430px;">
    <div class="easyui-layout" fit="true">
        <div data-options="region:'north'" style="height:35px;">
            <table style="margin-top: 5px">
                <tr>
                    <td style="width: 95px; text-align: center">期次</td>
                    <td>
                        <input id="ContractStages" name="ContractStages" class="easyui-combobox" style="width: 180px;" />
                    </td>
                </tr>
            </table>
        </div>
        <input id="hContractID" name="ContractID" type="hidden" value="@Model.ContractID" />
        <input id="hContractStagesID" name="ContractStagesID" type="hidden" value="@Model.ID" />

        <div data-options="region:'center'" style="height:385px; padding:10px;">
            <table id="estimateBillDataGrid" fit="true"></table>
        </div>
    </div>
</div>


